<template>
	<view class="gold-tab">
		<u-sticky>
			<u-tabs :list="tabs" :is-scroll="false" active-color="#000" bar-width="375" height="100" :current="current" @change="change"></u-tabs>
		</u-sticky>

		<view class="list">
			<my-order :date="i.created_at" :img="i.product_pic" :title="i.product_name" :price="i.price" :subTitle="i.merchant.merchant_name" :status="i.status_text" v-for="i in wait" :key="i.id">
				<template v-slot:btns>
					<view v-if="i.status_text=='待评价'" class="my-order-btn on" @click="$goto('/pages/comment/submit?no='+i.trade_no)">去评价</view>
				</template>
			</my-order>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabs: [{
					name: '待评价'
				}, {
					name: '已评价'
				}],
				current: 0,
				wait: [],
				done: []
			};
		},
		onShow() {
			this.getList(this.current);
		},
		methods: {
			change(index) {
				this.current = index;
				this.getList(index);
			},
			getList(index) {
				this.wait = []
				uni.showLoading({
					title: '加载中...',
					mask: true
				})
				if (index==0) {
					this.$u.get('/comment/wait').then(res => {
						this.wait = res.data.result.order
					})
				} else if (index==1) {
					this.$u.get('/comment/done').then(res => {
						this.wait = res.data.result.order
					})
				}
			}
		}
	}
</script>

<style lang="scss">

</style>
